#ifndef _PROCESS_SINGLETON_1134BB7C_18A4_48DC_A9CE_C7EF454A86D0_
#define _PROCESS_SINGLETON_1134BB7C_18A4_48DC_A9CE_C7EF454A86D0_
#pragma once

//#include "base/build_config.h"
#include <set>
#include <vector>

#include "base/basictypes.h"
#include "base/callback.h"
#include "base/command_line.h"
#include "base/file_path.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/process.h"
#include "base/threading/non_thread_safe.h"

namespace dl {

class ProcessSingleton : public base::NonThreadSafe {
public:
	typedef base::Callback<void(const std::string&)> NotificationCallback;

	explicit ProcessSingleton();
	~ProcessSingleton();
	bool FoundOtherProcessWindow() const;
	void NotifyOtherProcess(const std::string& pipe);
	void SetNotificationCallback(NotificationCallback cb);
	LRESULT WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
private:
	void Cleanup();
	LRESULT OnCopyData(HWND hwnd, const COPYDATASTRUCT* cds);
private:
	static const int kTimeoutInSeconds = 20;
	HWND window_, remote_window_;
	NotificationCallback notification_;
  DISALLOW_COPY_AND_ASSIGN(ProcessSingleton);
};

}

#endif  // _PROCESS_SINGLETON_1134BB7C_18A4_48DC_A9CE_C7EF454A86D0_
